package com.fyzk.activity.lottery.zc_new.adapter;


import android.app.ActionBar.LayoutParams;
import android.content.Context;
import android.graphics.Typeface;
import android.text.SpannableString;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.fyzk.bean.ZCGameQueueItem;
import com.tyjc.lottery.R;
import com.fyzk.utils.TextStyleUtil;

import java.util.List;

public class ZCSFCAdapter_New extends ZCBaseAdapter{

	public ZCSFCAdapter_New(Context context, List<ZCGameQueueItem> infors) {
		super(context, infors);
		// TODO Auto-generated constructor stub
	}

	@Override
	protected View getRightView(final ZCGameQueueItem data, int position) {
		// TODO Auto-generated method stub
		View rightView = LayoutInflater.from(context).inflate(R.layout.zc_adapter_sfc, null);
		TextView home_tv =  (TextView) rightView.findViewById(R.id.zc_sfc_home);
		TextView away_tv = (TextView) rightView.findViewById(R.id.zc_sfc_away);
		CheckBox sheng_check = (CheckBox) rightView.findViewById(R.id.zc_sfc_sheng);
		CheckBox ping_check = (CheckBox) rightView.findViewById(R.id.zc_sfc_ping);
		CheckBox fu_check = (CheckBox) rightView.findViewById(R.id.zc_sfc_fu);
		
		home_tv.setText(data.getHomeTeam());
		away_tv.setText(data.getAwayTeam());
		
		sheng_check.setChecked(data.isSheng());
		ping_check.setChecked(data.isPing());
		fu_check.setChecked(data.isFu());
		
	    
	    SpannableString spanString = TextStyleUtil.fontSizeSpan(new SpannableString("3 "), 18);
	    spanString = TextStyleUtil.styleSpan(spanString, Typeface.BOLD);
	    sheng_check.append(spanString);
	    spanString = TextStyleUtil.fontSizeSpan(new SpannableString(" ("+data.getVs_3()+")"), 12);
	    sheng_check.append(spanString);
	    
	    spanString = TextStyleUtil.fontSizeSpan(new SpannableString("1 "), 18);
	    spanString = TextStyleUtil.styleSpan(spanString, Typeface.BOLD);
	    ping_check.append(spanString);
	    spanString = TextStyleUtil.fontSizeSpan(new SpannableString(" ("+data.getVs_1()+")"), 12);
	    ping_check.append(spanString);
	    
	    spanString = TextStyleUtil.fontSizeSpan(new SpannableString("0 "), 18);
	    spanString = TextStyleUtil.styleSpan(spanString, Typeface.BOLD);
	    fu_check.append(spanString);
	    spanString = TextStyleUtil.fontSizeSpan(new SpannableString(" ("+data.getVs_0()+")"), 12);
	    fu_check.append(spanString);
		
		sheng_check.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				data.setSheng(!data.isSheng());
				if (data.isSheng()) {
					data.clickNum++;
				}else{
					data.clickNum--;
				}
				tongJi();
			}
		});
		
		ping_check.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				data.setPing(!data.isPing());
				if (data.isPing()) {
					data.clickNum++;
				}else{
					data.clickNum--;
				}
				tongJi();
			}
		});
		
		fu_check.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				data.setFu(!data.isFu());
				if (data.isFu()) {
					data.clickNum++;
				}else{
					data.clickNum--;
				}
				tongJi();
			}
		});
		
		LinearLayout.LayoutParams pl = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 
				LayoutParams.MATCH_PARENT, 1);
		rightView.setLayoutParams(pl);
		return rightView;
	}

}
